import sqlite3 from 'better-sqlite3'
import { is } from '@electron-toolkit/utils'

const verbose = false

class SQLiteDB {
  db: any
  constructor(dbFilePath) {
    this.db = new sqlite3(dbFilePath, { verbose: is.dev && verbose ? console.log : null })
  }

  run(sql, params: any = []) {
    this.db.prepare(sql).run(params)
  }

  get(sql, params = []) {
    return this.db.prepare(sql).get(params)
  }

  all(sql, params = []) {
    return this.db.prepare(sql).all(params)
  }

  close() {
    this.db.close
  }
}

export default SQLiteDB
